<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="./js/echarts.min.js"></script>
    <script src="./js/jshx.echarts.1.0.js"></script>
    <title>饼状图demo</title>
    <style>
        .demo {
            margin: 50px auto;
            width: 80%;
            height: 600px;
        }

        #main6 {
            width: 60%;
            height: 450px;
        }

        #main7 {
            width: 40%;
            height: 300px;
        }

        #button {
            margin-left: 30%;
            margin-top: 50px;
        }

        #button1 {
            margin-top: 50px;
        }

        #button2 {
            margin-top: 50px;
        }
    </style>
</head>

<body>
    <div id="main" class="demo"></div>
    <hr>
    <button id="button">点此更新已有数据putData</button>
    <button id="button1">点此新增随机数据putData</button>
    <button id="button2">点此清除数据clearData</button>
    <div id="main1" class="demo"></div>
    <hr>
    <div id="main2" class="demo"></div>
    <hr>
    <div id="main3" class="demo"></div>
    <hr>
    <div id="main4" class="demo"></div>
    <hr>
    <div id="main5" class="demo"></div>
    <div id="main6" class="demo"></div>
    <div id="main7" class="demo"></div>
    <script>
        var main = new HxChartPie('main', '普通饼状图');
        main.putData('直接访问', 335);
        main.putData('邮件营销', 310);
        main.putData('联盟广告', 234);
        main.putData('视频广告', 135);
        main.putData('搜索引擎', 1548);
        main.setCbClick(function (param) {
            console.log(param)
        })

        var main1 = new HxChartPie('main1', '点击上方按钮新增数据:putData');
        main1.init();
        main1.putData('初始数据1', 335);
        main1.putData('初始数据2', 310);
        document.getElementById('button').addEventListener("click", function () {
            main1.putData('初始数据1', Math.ceil(Math.random() * 1000));
            main1.putData('初始数据2', Math.ceil(Math.random() * 1000));
        })

        var num = 1;
        document.getElementById('button1').addEventListener("click", function () {
            main1.putData('第' + num + '次点击', Math.ceil(Math.random() * 1000));
            num++;
        })

        document.getElementById('button2').addEventListener("click", function () {
            main1.clearData();
            num = 1;
        })

        var main2 = new HxChartPie('main2');
        main2.init();
        main2.putData('直接访问', 335);
        main2.putData('邮件营销', 310);
        main2.putData('联盟广告', 234);
        main2.putData('视频广告', 135);
        main2.putData('搜索引擎', 1548);
        main2.setCircular();

        var main3 = new HxChartPie('main3', '修改标题位置:setTitleLocation');
        main3.init();
        main3.putData('直接访问', 335);
        main3.putData('邮件营销', 310);
        main3.putData('联盟广告', 234);
        main3.putData('视频广告', 135);
        main3.putData('搜索引擎', 1548);
        main3.setTitleLocation('l');

        var main4 = new HxChartPie('main4');
        main4.init();
        main4.putData('直接访问', 335);
        main4.putData('邮件营销', 310);
        main4.putData('联盟广告', 234);
        main4.putData('视频广告', 135);
        main4.putData('搜索引擎', 1548);
        main4.setTitle('修改标题:setTitle');

        var main5 = new HxChartPie('main5', '修改字体:setSize');
        main5.init();
        main5.putData('直接访问', 335);
        main5.putData('邮件营销', 310);
        main5.putData('联盟广告', 234);
        main5.putData('视频广告', 135);
        main5.putData('搜索引擎', 1548);
        main5.setSize('l');
        var main6 = new HxChartPie('main6', '修改字体:setSize');
        main6.init();
        main6.putData('直接访问', 335);
        main6.putData('邮件营销', 310);
        main6.putData('联盟广告', 234);
        main6.putData('视频广告', 135);
        main6.putData('搜索引擎', 1548);
        main6.setSize('m');
        var main7 = new HxChartPie('main7', '修改字体:setSize');
        main7.init();
        main7.putData('直接访问', 335);
        main7.putData('邮件营销', 310);
        main7.putData('联盟广告', 234);
        main7.putData('视频广告', 135);
        main7.putData('搜索引擎', 1548);
        main7.setCircular();
        main7.setSize('s');
    </script>
</body>

</html>